package com.me.modules.sys.service.impl;

import com.me.modules.common.common.Constant;
import com.me.modules.common.page.Page;
import com.me.modules.common.page.PageHelper;
import com.me.modules.common.utils.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.*;

import com.me.modules.sys.dao.TimetblInfoDao;
import com.me.modules.sys.entity.TimetblInfoEntity;
import com.me.modules.sys.service.TimetblInfoService;



@Service("timetblInfoService")
public class TimetblInfoServiceImpl implements TimetblInfoService {
	@Autowired
	private TimetblInfoDao timetblInfoDao;

	@Override
	public TimetblInfoEntity queryObject(Long id){
		return timetblInfoDao.queryObject(id);
	}

	@Override
	public List<TimetblInfoEntity> queryList(Map<String, Object> map){
		return timetblInfoDao.queryList(map);
	}

    @Override
    public List<TimetblInfoEntity> queryListByBean(TimetblInfoEntity entity) {
        return timetblInfoDao.queryListByBean(entity);
    }

	@Override
	public int queryTotal(Map<String, Object> map){
		return timetblInfoDao.queryTotal(map);
	}

	@Override
	public int save(TimetblInfoEntity timetblInfo){
		timetblInfo.setCreateUser(UserUtils.getCurrentUser().getUserName());
		timetblInfo.setCreateDate(new Date());
//		timetblInfo.setStatus("0");
		return timetblInfoDao.save(timetblInfo);
	}

	@Override
	public int update(TimetblInfoEntity timetblInfo){
		timetblInfo.setUpdateUser(UserUtils.getCurrentUser().getUserName());
		timetblInfo.setUpdateDate(new Date());
		//timetblInfo.setStatus("0");
		return timetblInfoDao.update(timetblInfo);
	}

	@Override
	public int delete(Long id){
        return timetblInfoDao.delete(id);
	}

	@Override
	public int deleteBatch(Long[] ids){
        return timetblInfoDao.deleteBatch(ids);
	}

	@Override
	public Page<TimetblInfoEntity> findPage(TimetblInfoEntity timetblInfo, int pageNum) {
		PageHelper.startPage(pageNum, Constant.pageSize);
		timetblInfoDao.queryList(timetblInfo);
		return PageHelper.endPage();
	}


	@Override
	public List<Map<String, Object>> queryMapList() {
		List<TimetblInfoEntity> list =timetblInfoDao.queryList(null);
		List<Map<String, Object>> worktimeList =new ArrayList<Map<String, Object>>();
		for (TimetblInfoEntity timetblInfo:list) {
			Map<String, Object> map =new HashMap<String, Object>();
			map.put("value",timetblInfo.getId());
			map.put("name",timetblInfo.getName());
			worktimeList.add(map);
		}
		return  worktimeList;
	}
}
